/*
 * 创建日期 2006-5-10
 *
 * 更改所生成文件模板为
 * 窗口 > 首选项 > Java > 代码生成 > 代码和注释
 */
package com.aia.estoreweb.jsptag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * @author hejinghua
 *
 * 更改所生成类型注释的模板为
 * 窗口 > 首选项 > Java > 代码生成 > 代码和注释
 */
public class HbxTag extends TagSupport
{
	private String title;
	private String step;

	public int doEndTag() throws JspException
	{
		JspWriter jw = super.pageContext.getOut();
		try
		{
			jw.write(this.getEndStr().toString());
		}
		catch (IOException e)
		{
			throw new JspException(e.getMessage());
		}
		return super.doStartTag();
	}
	private StringBuffer getStartStr()
	{
		StringBuffer sb = new StringBuffer();
		//sb.append("<!--WEBSIDESTORY CODE HBX1.0 (Universal)-->\n");
		//sb.append("<!--COPYRIGHT 1997-2005 WEBSIDESTORY,INC. ALL RIGHTS RESERVED. U.S.PATENT No. 6,393,479B1. MORE INFO:http://websidestory.com/privacy-->\n");
		sb.append("<script language='javascript' src='theme/hbxmodify.js'></script>\n");
		//sb.append("<!--  Override Default HBX values -->\n");
		sb.append("<script language='javascript1.1'>\n");
		sb.append("hbx.acct ='DM5602280HED;DM551122AHNN;DM551122MBWD';\n");
		if(step!=null && step.length()>0)
		{
			//sb.append("hbx.fnl='(49611,"+step+")';");
		}
		sb.append("hbx.mlc='CONTENT+CATEGORY;/Life+Insurance/Asia/China/AIA+China-eStore;/Life+Insurance/Asia/China/Foreign+Life/AIA+China-eStore/'+ document.location.host + '-' + cleanCharacters(document.title); \n");
		sb.append("</script>\n");
		
		if (title == null || title.length()==0) title = "empty";		
		sb.append("<script language='javascript1.1'>\n");
		sb.append("hbx.pn='" + title + "';\n");
		//sb.append("alert(hbx_title);\n");
		sb.append("hbx.mlc='CONTENT+CATEGORY;/Life+Insurance/Asia/China/AIA+China-eStore;/Life+Insurance/Asia/China/Foreign+Life/AIA+China-eStore/'+document.location.host;\n");
		sb.append("</script>\n");
		return sb;
	}

	public int doStartTag() throws JspException
	{
		JspWriter jw = super.pageContext.getOut();
		try
		{
			jw.write(this.getStartStr().toString());
		}
		catch (IOException e)
		{
			throw new JspException(e.getMessage());
		}
		return super.EVAL_PAGE;
	}
	private StringBuffer getEndStr()
	{
		StringBuffer sb = new StringBuffer();
		//sb.append("<!--WEBSIDESTORY CODE HBX1.0 (Universal)-->\n");
		//sb.append("<!--COPYRIGHT 1997-2005 WEBSIDESTORY,INC. ALL RIGHTS RESERVED. U.S.PATENT No. 6,393,479B1. MORE INFO:http://websidestory.com/privacy-->\n");
		sb.append("<script language='javascript1.1' defer src='theme/hbx.js'></script>\n");
		//sb.append("<!--END WEBSIDESTORY CODE-->\n");
		return sb;
	}

	/**
	 * @return
	 */
	public String getTitle()
	{
		return title;
	}

	/**
	 * @param string
	 */
	public void setTitle(String string)
	{
		title = string;
	}

	/**
	 * @return
	 */
	public String getStep()
	{
		return step;
	}

	/**
	 * @param string
	 */
	public void setStep(String string)
	{
		step = string;
	}

}
